<style lang='scss' type='stylesheet/scss' scoped>
</style>

<template>
  <div class="as-checkbox-group">
    <slot></slot>
  </div>
</template>

<script type='text/ecmascript-6'>
export default {
  name: "AsCheckboxGroup",
  componentName: "AsCheckboxGroup",
  props: {
    value: {
      type: Array,
      default: []
    }
  },
  data() {
    return {};
  },
  created() {
    this.$on("handlerChange", val => {
      let value = [...this.value];
      if (value.includes(val)) {
        value.splice(value.indexOf(val), 1);
      } else {
        value.push(val);
      }
      this.$emit("input", value);
      this.$emit("change", value);
      this.$nextTick(_ => {
        this.$forceUpdate();
      });
    });
  }
};
</script>
